/**
 * Created by henian.xu on 2017/3/3.
 * gulp 构建文件
 */

var
  gulp = require('gulp'),
  sass = require('gulp-sass'),
  sourcemaps = require('gulp-sourcemaps');


//**-- 配置文件 --**//
var
  src = {
    sass: ['./static/sass/**/*.scss','./static/sass/**/*.sass'],
    libs: './libs/**/*.js',
    js: './src/**/*.js',
    ts: './src/**/*.ts'
  },
  dest = {
    sass: './static/sass',
    libs: './build/libs',
    js: './build',
    ts: './src'
  },
  useMap = true;

//**-- 构建 --**//
gulp.task('B:sass', function () {
  var
    task = gulp.src(src.sass);
  useMap && (task = task.pipe(sourcemaps.init()));
  task = task.pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError));
  useMap && (task = task.pipe(sourcemaps.write()));
  task = task.pipe(gulp.dest(dest.sass));
  return task;
});

//**-- 监听 --**//
gulp.task('W:all', function () {
  gulp.watch([src.sass], ['B:sass']);
});


